import { httpRequest } from '@/api/httpRequest'

function useDetermine() {



  setTimeout(() => {
    initData()
  }, 2000);
  
  function initData() {

    console.log(44444444);
    
    let wmsobj = earth.sceneTree.root.children.push({
      ref: 'pandulayer',
      czmObject: {
        xbsjType: "Imagery",
        name: 'pandulayer',
        // name: item.keywords == "" ? item.filename : item.keywords,
        xbsjImageryProvider: {
          XbsjImageryProvider: {},
          UrlTemplateImageryProvider: {},
          WebMapServiceImageryProvider: {},
          WebMapTileServiceImageryProvider: {},
          ArcGisMapServerImageryProvider: {},
          GoogleEarthEnterpriseImageryProvider: {},
          createTileMapServiceImageryProvider: {},
          TileMapServiceImageryProvider: {},
          type: "WebMapServiceImageryProvider",
        },
      },
    });

  }

  function loadTif(name) {

    console.log(earth.sceneTree);
    console.log(earth.sceneTree.$refs);

    earth.sceneTree.$refs[
      'pandulayer'
    ].czmObject.xbsjImageryProvider.WebMapServiceImageryProvider._imageryProvider = new Cesium.WebMapServiceImageryProvider(
      {
        // 这里是你的 geoserver服务点击查看图层的 url
        url: "/imgexpress/wms",
        // 这里是自定义的图层名称
        parameters: {
          service: "WMS",
          FORMAT: "image/png",
          version: '1.3.0',
          TRANSPARENT: true,
          LAYERS: `${name}`,
          crs: 'EPSG:4326'
          // LAYERS: "test_tif:TRIPLESAT_2_MS_L1_20201226020854_002764VI_003",
        },
      }
    );
    
  }

  function removeTif(params) {
    earth.sceneTree.$refs[
      'pandulayer'
    ].czmObject.destroy()
  }

    return {loadTif, removeTif}
}

export default useDetermine
